﻿#ifndef ANALYZER_ALGORITHM_H
#define ANALYZER_ALGORITHM_H

#include <string>
#include <vector>
#include <locale>
#include <opencv2/opencv.hpp>    //opencv header file
#include "ModelConfig.h"
#include "Utils/AlgUtils.h"
#ifdef  WIN32
#endif //  WIN32

namespace AVSAnalyzer {
    class Config;
    class AlgorithmConfig;

    struct DetectObject
    {
        int x1;                 // 检测框左上角x坐标
        int y1;                 // 检测框左上角y坐标
        int x2;                 // 检测框右下角x坐标
        int y2;                 // 检测框右下角y坐标
        float class_score;      // 检测置信度分数
        int class_id;           // 检测类别ID
        std::string class_name; // 检测类别名称
    };  

    class Algorithm
    {
    public:
        Algorithm(const AlgorithmConfig& algorithmConfig) : 
            mAlgorithmConfig(algorithmConfig),
            mCreateState(false) {}
        virtual ~Algorithm() = default;

        // 获取算法配置
        const AlgorithmConfig& getConfig() const { return mAlgorithmConfig; }

        virtual bool objectDetect(cv::Mat& image, std::vector<DetectObject>& detects) = 0;
        bool createState()
        {
            if (!mCreateState)
            {
                mCreateState = true;
                return true;
            }
            return false;
        }

    protected:
        AlgorithmConfig mAlgorithmConfig;
        bool mCreateState;  //创建状态，默认false
    };


}
#endif //ANALYZER_ALGORITHM_H

